<template>
  <div class="wrap">
    <div class="logoWrap">
      <div class="logo"><img src="../assets/static/logo.jpg" alt=""></div>
      <div class="logo_content">中科院力学所综合管理平台医药费管理系统</div>
    </div>
    <div class="ctn">
      <div class="loginWrap">
        <div class="title">登录</div>
        <!-- 登录表单区域 -->
        <el-form ref="loginFormRef" :model="loginForm" :rules="loginFormRules" label-width="0px" class="login_form">
          <!-- 用户名 -->
          <el-form-item prop="username">
            <el-input v-model="loginForm.username" prefix-icon="el-icon-user-solid"></el-input>
          </el-form-item>
          <!-- 密码 -->
          <el-form-item prop="password">
            <el-input v-model="loginForm.password" prefix-icon="el-icon-lock" type="password"></el-input>
          </el-form-item>
          <!-- 按钮区域 -->
          <el-form-item class="btns">
            <el-button type="primary" @click="login">登录</el-button>
            <el-button type="info" @click="resetLoginForm">重置</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <div class="bottom">
      <div class="line"></div>
      <span>Copyright © 2020 王泽 版权所有</span>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      // 登陆表单的数据绑定对象
      loginForm: {
        username: 'wz',
        password: '123'
      },
      // 表单的验证规则对象
      loginFormRules: {
        // 验证用户名是否合法
        username: [
          { required: true, message: '请输入用户名', trigger: 'blur' },
          { max: 20, message: '长度不能超过二十个字符', trigger: 'blur' }
        ],
        // 验证密码是否合法
        password: [
          { required: true, message: '请输入登录密码', trigger: 'blur' },
          { min: 6, max: 20, message: '长度在 6 到 20 之间', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    // 点击重置按钮, 重置登陆表单
    resetLoginForm () {
      this.$refs.loginFormRef.resetFields()
    },
    login () {
      this.$refs.loginFormRef.validate(valid => {
        console.log(valid)
      })
    }
  }
}
</script>
<style lang="less" scoped>
  .wrap {
    height: 100%;
  }
  .logoWrap {
    height: 80px;
    margin-left: 80px;
    margin-top: 20px;
  }
  .logo {
    float: left;
    width: 60px;
    height: 60px;
  }
  .logo img{
    width: 100%;
    height: 100%;
  }
  .logo_content {
    float: left;
    font-size: 25px;
    color: darkblue;
    line-height: 60px;
    height: 60px;
  }
  .ctn {
    background: url(../assets/static/bg.jpg) no-repeat;
    background-size: cover;
    height: 70%;
    position: relative;
  }
  .loginWrap {
    position: absolute;
    right: 10%;
    width: 290px;
    height: 280px;
    background: rgba(255, 255, 255, 0.5);
    margin-top: -210px;
    top: 50%;
    padding: 30px 30px 90px;
  }
  .loginWrap .title{
    color: rgb(35, 118, 188);
    font-size: 34px;
    text-align: center;
    font-family: PingFangSC-Regular;
    margin-bottom: 40px;
  }
  .login_form{
    width: 100%;
    padding: 0 0;
  }
  .btns {
    margin-top: 50px;
    display: flex;
    justify-content: flex-end;
  }
  .bottom {
    width: 80%;
    text-align: center;
    color: rgba(144, 144, 144, 1);
    font-size: 14px;
    font-family: PingFangSC-Regular;
    margin: 20px auto 0;
  }
  .bottom span {
    margin-top: 15px;
    display: inline-block;
  }
  .line {
    border: 1px solid rgba(0, 0, 0, 0.1);
  }
</style>
